<template>
  <div class="box">
    <van-cell>
      <!-- 使用 title 插槽来自定义标题 -->
      <template slot="title">
        <span class="custom-title"><span v-if='list!=undefined'>{{list.name}}</span></span>
      </template>
    </van-cell>
    <van-field
      v-model="message"
      rows="5"
      type="textarea"
      placeholder="跟赞理由"
    />
    <div style="margin:15px;"><van-button round type="info" @click="showHome(list.id)">跟赞</van-button></div>
  
  </div>
</template>

<script type="text/javascript">
import { Cell, CellGroup, Field ,Button } from "vant";
export default {
  data() {
    return {
        message:'',
        list:[]
    };
  },
  components: {
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Field.name]: Field,
    [Button.name]:Button 
  },
  created(){
    this.getFollow()
  },
  methods:{
    // 数据渲染
    async getFollow(){
      let userId = localStorage.getItem("userId");
      let corpId = localStorage.getItem("custid");
      const id=this.$route.query.id;
      const res = await this.$http.get(`yuepoints/hezanInfo?corpId=${corpId}&userId=${userId}&id=${id}`)
      this.list=res.data.data;
    },
     // 跟赞
     async showHome(id){
       let userId = localStorage.getItem("userId");
       let corpId = localStorage.getItem("custid");
        const val=this.message;
        const res = await this.$http.get(`yuepoints/hezan?corpId=${corpId}&userId=${userId}&id=${id}&desc=${val}`)
       if(res.data.errcode=='0000'){
         this.$router.push({
        //核心语句
        path: "/home", 
        query: {
          //路由传参时push和query搭配使用 ，作用时传递参数
          showmenu: false,
          active:1,
        }
      });
       }else{
         this.$toast(res.data.errmsg)
       }
      }
  }
};
</script>

<style lang="less" scoped>
.box {
  text-align: left;
  /deep/ .van-field{
    border-bottom: 1px solid #c0c0c06e;
    border-top: 1px solid #c0c0c06e;
  }
  /deep/ .van-cell{
 font-size: 16px;
  }
  /deep/ .van-button {
      width: 100%
  }
}
</style>
